package com.kgc.service.impl;

import com.kgc.dao.FaqsDao;
import com.kgc.entity.Classes;
import com.kgc.entity.Faqs;
import com.kgc.service.FaqsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class FaqsServiceImpl implements FaqsService {
    @Autowired
  private FaqsDao faqsDao;

    @Override
    @Transactional(readOnly = true)
    public List<Faqs> listFaqs(String name) {
        Map<String,Object> paramMap = new HashMap<String,Object>();
    if (name!=null && !"".equals(name)){
        paramMap.put("name",name);
    }
        return faqsDao.listFaqs(paramMap);
    }

    @Override
    @Transactional(readOnly = true)
    public List<Classes> listClasses() {
        return faqsDao.listClasses();
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public int insert(Faqs faqs) {
        return faqsDao.insert(faqs);
    }

    @Override
    @Transactional(readOnly = true)
    public Faqs select(int id) {
        return faqsDao.select(id);
    }

    @Override
    @Transactional(readOnly = true)
    public int count(String title) {
        return faqsDao.count(title);
    }

    @Override
    @Transactional(readOnly = true)
    public int countByName(String name) {
        return faqsDao.countByName(name);
    }
}
